<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You under the Apache License, Version 2.0
  ~ (the "License"); you may not use this file except in compliance with
  ~ the License.  You may obtain a copy of the License at
  ~
  ~    http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  ~
  -->

<sp-table fxFlex="100" [columns]="displayedColumns" [dataSource]="dataSource">
    <ng-container matColumnDef="filename">
        <th mat-header-cell *matHeaderCellDef>Filename</th>
        <td mat-cell *matCellDef="let fileMetadata">
            <h4>{{ fileMetadata.filename }}</h4>
        </td>
    </ng-container>
    <ng-container matColumnDef="filetype">
        <th mat-header-cell *matHeaderCellDef>Filetype</th>
        <td mat-cell *matCellDef="let fileMetadata">
            <span
                class="filetype-container"
                [style.background-color]="getFileColor(fileMetadata.filetype)"
                >{{ fileMetadata.filetype }}</span
            >
        </td>
    </ng-container>
    <ng-container matColumnDef="uploaded">
        <th mat-header-cell *matHeaderCellDef>Uploaded</th>
        <td mat-cell *matCellDef="let fileMetadata">
            <h5>
                {{ fileMetadata.createdAt | date: 'dd.MM.yyyy HH:mm' }}
            </h5>
        </td>
    </ng-container>

    <ng-container matColumnDef="action">
        <th mat-header-cell *matHeaderCellDef></th>
        <td mat-cell *matCellDef="let fileMetadata">
            <div fxLayout="row" fxLayoutAlign="end center">
                <button
                    color="accent"
                    mat-icon-button
                    matTooltip="Download File"
                    matTooltipPosition="above"
                    (click)="downloadFile(fileMetadata)"
                    data-cy="download"
                >
                    <i class="material-icons">download</i>
                </button>
                <button
                    color="accent"
                    mat-icon-button
                    matTooltip="Delete file"
                    matTooltipPosition="above"
                    (click)="deleteFile(fileMetadata)"
                    data-cy="delete"
                >
                    <i class="material-icons">delete</i>
                </button>
            </div>
        </td>
    </ng-container>
</sp-table>
